# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=cairomm
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.12.2
pkgrel=2
pkgdesc="C++ bindings to Cairo vector graphics library (mingw-w64)"
arch=('any')
url="https://www.cairographics.org/"
license=("LGPL, MPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "${MINGW_PACKAGE_PREFIX}-glib2")
depends=( "${MINGW_PACKAGE_PREFIX}-libsigc++" "${MINGW_PACKAGE_PREFIX}-cairo")
options=(strip staticlibs)
source=("https://www.cairographics.org/releases/cairomm-${pkgver}.tar.gz")
sha256sums=('45c47fd4d0aa77464a75cdca011143fea3ef795c4753f6e860057da5fb8bd599')

build() {
  CPPFLAGS+=" -D_REENTRANT -D_POSIX_SOURCE"
  export lt_cv_deplibs_check_method='pass_all'
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --disable-documentation

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
